package com.daoserver.mq;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

/**
 *  发送消息
 * 
 * @author super
 *
 */
@Service
@Component
public class RabbitSender {
	private static final Log logger = LogFactory.getLog(RabbitSender.class);

	@Autowired
	private OutPutBarista source;

	// 发送消息
	public String sendMessage(String message) {
		try {
			String msg = "message:" + message;
			source.outPut().send(MessageBuilder.withPayload(msg).build());
			logger.info("发送成功:" + msg);

		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return null;
	}
}